import ApiService from '@/services/api.service'

class LabelService {
  constructor() {
    this.request = ApiService
  }

  getLabelList(projectId, userId) {
    return this.request.get(`/projects/${projectId}/labels`)
  }

  // 用户分配条数
  getUserLabelsNumber(userid, projectid, number) {
    return this.request.get(`/workDistribution?userId=${userid}&projectId=${projectid}&number=${number}`)
  }

  // 2021.7.29 简单分类
  getNormalLabelList() {
    return this.request.get('/projects/1/labels')
  }

  // 2021.8.11 复杂更新分类
  getLabels() {
    return this.request.get('/projects/GetLabels?projectId=2')
  }

  getLabelsBig() {
    return this.request.get('/projects/GetLabels?projectId=3')
  }

  // 2021.7.29 复杂分类
  getComplexLabelList() {
    return this.request.get('/projects/2/labels')
  }

  // 2021.7.29 大分类 顶级分类
  getTopLevelLabelList() {
    return this.request.get('/projects/3/labels')
  }

  // 2021.7.28  所有大分类

  // getTotalLabelList(projectId) {
  //   return this.request.get(`/projects/${projectId}/totalLabels`)
  // }

  // 2021.7.28  提交radio

  addRadio(projectId, payload) {
    return this.request.post(`/projects/${projectId}/radio`, payload)
  }

  addLabel(projectId, payload) {
    return this.request.post(`/projects/${projectId}/labels`, payload)
  }

  deleteLabel(projectId, labelId) {
    return this.request.delete(`/projects/${projectId}/labels/${labelId}`)
  }

  updateLabel(projectId, labelId, payload) {
    return this.request.patch(`/projects/${projectId}/labels/${labelId}`, payload)
  }

  uploadFile(projectId, payload, config = {}) {
    return this.request.post(`/projects/${projectId}/label-upload`, payload, config)
  }
}

export default new LabelService()
